# -*- coding:utf-8 -*-
# @Author: shenyuyu
# @Time: 2023/6/26 11:08
# @File: qu_5_take_top_count_takeSample.py
from pyspark import SparkConf, SparkContext
from operator import add

if __name__ == '__main__':
    conf = SparkConf().setAppName("test").setMaster("local[*]")
    sc = SparkContext(conf=conf)

    rdd = sc.parallelize([1, 2, 3, 4, 5, 6])

    rdd1 = rdd.first()
    print(rdd1)

    rdd2 = rdd.top(2)
    print(rdd2)

    rdd3 = rdd.take(2)
    print(rdd3)

    rdd4 = rdd.count()
    print(rdd4)

    print(rdd.takeSample(True, 50))
    print(rdd.takeSample(False, 50))